package com.evaluationsystem.system.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class UserInfo implements UserDetails {
    /**
    * 用户ID
    */
    private String userid;

    /**
    * 用户名称
    */
    private String username;

    /**
    * 密码
    */
    private String password;

    /**
    * 作成者
    */
    private String insuserid;

    /**
    * 作成时间
    */
    private String insdate;

    /**
    * 更新者
    */
    private String upduserid;

    /**
    * 更新时间
    */
    private String upddate;

    /**
     * 1：启用状态，0：禁用状态
     */
    private String vtypt;



    @JsonIgnore
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @JsonIgnore
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @JsonIgnore
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @JsonIgnore
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @JsonIgnore
    @Override
    public boolean isEnabled() {
        if (this.vtypt.equals("0"))return false;else return true;
    }
}